
using OhioState.AssetManaged;
using OhioState.Graphics;
using OhioState.Graphics.Proxy;


namespace OhioState.Graphics.OpenGL
{
    public class SphereHandler : OpenGLObject, IDrawable
    {
        private SphereProxy _sphereProxy;
        private SphereGL _realSphere;
        public SphereHandler(SphereProxy proxyObj)
            : base(proxyObj)
        {
            _sphereProxy = proxyObj;
            _realSphere = new SphereGL(_sphereProxy.Sphere.Radius);
        }
        public void Render(IRenderPanel panel)
        {
            Update(panel);
            _realSphere.Render(panel);
                
        }

        public override void Update(IRenderPanel panel)
        {
            if (this.Invalid)
            {
                this.Invalid = false;
                _realSphere.Material = panel.ResourceManager.GetItem(_sphereProxy.Material as IAssetManaged) as IMaterial;
                _realSphere.Wireframe = _sphereProxy.Wireframe;
            }
        }

        public IMaterial Material
        {
            get { return _sphereProxy.Material; }
            set { }
        }
        public IBoundingVolume BoundingVolume
        {
            get { return null; }
        }
    }
}
